/**
 * Test function to check whether Formal Context is sorted properly
 *
 * author: Marcin Wachulski
 *
 */
#include "OK.h"

bool is_sorted(const FormalContext &fc) {
    if (fc.processedNo > 1)
        for (std::vector<OAPair>::const_iterator i = fc.data.begin();
            (i+1) != fc.data.begin() + fc.processedNo; i++)
            if (i->first->data.size() > (i+1)->first->data.size())
                return false;
    if (fc.data.size() - fc.processedNo > 1)
        for (std::vector<OAPair>::const_iterator i = fc.data.begin() + fc.processedNo;
            (i+1) != fc.data.end(); i++)
            if (i->first->data.size() > (i+1)->first->data.size())
                return false;
    return true;
}